/*
 * Copyright (c) 2018, ZeeSec Technologies. All rights reserved.
 * ZeeSec PROPRIETARY/CONFIDENTIAL.
 */

package springtest.controller;

import java.io.FileInputStream;
import java.io.OutputStream;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author ZhiQiang Chen
 * @date 2018-08-17 11:37:56
 */
@Controller
public class ReportController {

    @RequestMapping("/report")
    public String showReportView() {
        return "/ChangeReport/ChangeReport";
    }

    @RequestMapping("/report/show")
    public void showHtml(HttpServletResponse response) throws Exception {
        String pdfName = "test1.html";// pdf名字
        response.setHeader("Content-disposition", "inline;filename=" + pdfName);// 响应头为在线查看
        response.setContentType("text/html; charset=utf-8");
        OutputStream os = response.getOutputStream();
        FileInputStream fis = new FileInputStream("E:/00m2/test1.html");
        int count = 0;
        byte[] buffer = new byte[1024 * 1024];
        while ((count = fis.read(buffer)) != -1)
            os.write(buffer, 0, count);
        os.flush();
        if (os != null)
            os.close();
        if (fis != null)
            fis.close();
    }
}
